package org.example.builder.improve;

import org.junit.Test;

/**
 * @author
 * @description 指挥者 这里指制定制作流程 返回产品
 */
public class HouseDirector {

    protected HouseBuilder houseBuilder = null;

    protected HouseType houseType;

    /**
     * 有参构造方法  构造器传入HouseBuilder
     *
     * @param houseBuilder
     */
    public HouseDirector(HouseBuilder houseBuilder) {
        this.houseBuilder = houseBuilder;
    }

    /**
     * 通过setter方法传入HouseBuilder
     * @param houseBuilder
     * @author wf
     */
    public void setHouseBuilder(HouseBuilder houseBuilder) {
        this.houseBuilder = houseBuilder;
    }

    public void setHouseType(HouseType houseType) {
        this.houseType = houseType;
    }

    /**
     * 如何构建房子的流程交给指挥者
     * @return
     * @author
     */
    public House constructHouse() {
        houseBuilder.buildBasic();
        houseBuilder.buildWall();
        houseBuilder.roofed();
        if (houseBuilder instanceof HighBuilding) {
            ((HighBuilding) houseBuilder).yard();
        }
        return houseBuilder.buildHouse();
    }


}
